package com.aistar.service.impl;

import com.aistar.mapper.MemberMapper;
import com.aistar.mapper.jdbc.MemberMapperImpl;
import com.aistar.pojo.Member;
import com.aistar.service.MemberService;
import org.springframework.stereotype.Service;

/**
 * dependency injection [DI]
 * service 依赖于 mapper
 *
 * mapper 对象 如何注入到 service中？
 *
 * （1）构造器注入
 * （2）setter 注入
 */
@Service //<bean id="memberServiceImpl" class="com.aistar.service.impl.MemberServiceImpl">
public class MemberServiceImpl2 implements MemberService {


    private  MemberMapper mapper ;   // <bean id="memberMapperImpl" class="..MemberMapperImpl">

    public MemberServiceImpl2(){}
    public MemberServiceImpl2(MemberMapper mapper) {
        this.mapper = mapper;
    }


    public void setMapper(MemberMapper mapper) {
        this.mapper = mapper;
        System.out.println("mapper = " + mapper);

    }

    @Override
    public Member getById(int id) {
        MemberMapper mapper = new MemberMapperImpl();
        return  mapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean save(Member member) {
        return false;
    }

    @Override
    public boolean update(Member member) {
        return false;
    }

    @Override
    public boolean delete(int id) {
        return false;
    }



    @Override
    public boolean getByOthers(String memberName, String memberPwd) {
        return false;
    }

    @Override
    public void updateScore(Member m1, Member m2) {

    }
}
